#include <cassert>
#include <ostream>
#include <sstream>
#include <string>

#include "Predator.h"
#include "State/Game/PredatorStates.h"


Predator::Predator()
: BaseEntity()
, m_currentPreyID(-1)
{
	m_stateMachine = new StateMachine<Predator>(this);
	m_stateMachine->ChangeCurrentState(PredatorStateSeek::GetInstance());
}


Predator::~Predator()
{
	delete m_stateMachine;
}

void Predator::Update()
{
	assert(m_stateMachine && "<Predator::Update()>: m_stateMachine == NULL");
	if (m_stateMachine)
	{
		m_stateMachine->Update();
	}
}

bool Predator::HandleMessage(const Message& message)
{
	assert(m_stateMachine && "<Predator::HandleMessage()>: m_stateMachine == NULL");
	
	if (m_stateMachine)
	{
		return m_stateMachine->HandleMessage(message);
	}

	return false;
}

std::string Predator::GetEnityName()
{
	std::ostringstream oss;
	oss << "Predator_" << ID();
	
	return oss.str();
}

StateMachine<Predator>* Predator::GetStateMachine() const
{
	return m_stateMachine;
}

AITypes::EntityID Predator::GetCurrentPreyID() const
{
	return m_currentPreyID;
}

void Predator::SetCurrentPreyID(AITypes::EntityID id)
{
	m_currentPreyID = id;
}